package com.tubi.Period;

import java.time.LocalDate;
import java.time.Period;

//计算两个时间的间隔
public class Period1 {
    public static void main(String[] args) {
        //| public static Period between(开始时间,结束时间) | 计算两个“时间"的间隔 |
        LocalDate of = LocalDate.of(2010, 11, 21);
        LocalDate of1 = LocalDate.of(2011, 12, 24);
        Period between = Period.between(of, of1);
        System.out.println(between);//P1Y1M3D


        //| public int getYears()                           | 获得这段时间的年数   |
        int years = between.getYears();
        System.out.println(years);


        //| public int getMonths()                          | 获得此期间的总月数   |
        int months = between.getMonths();
        System.out.println(months);


        //| public int getDays()                            | 获得此期间的天数     |
        int days = between.getDays();
        System.out.println(days);

        
        //| public long toTotalMonths()                     | 获取此期间的总月数   |
        long l = between.toTotalMonths();
        System.out.println(l);
    }
}
